// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class ORDER_DETAIL_RAS_O01 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("32 RXO",32)]
  	    [HL7Field(HL7Version.v23, 32, HL7Repeat.False, HL7Required.True,"RXO")]
	    public RXO RXO {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("33 ORDER_DETAIL_SUPPLEMENT",33)]
  	    [HL7Field(HL7Version.v23, 33, HL7Repeat.False, HL7Required.False,"ORDER_DETAIL_SUPPLEMENT_RAS_O01")]
	    public ORDER_DETAIL_SUPPLEMENT_RAS_O01 ORDER_DETAIL_SUPPLEMENT {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			RXO = PopSegmentParseAndCheckRequired<RXO>(availableData, options, "RXO");
			ORDER_DETAIL_SUPPLEMENT = ProcessGroup<ORDER_DETAIL_SUPPLEMENT_RAS_O01>(availableData, options, "ORDER_DETAIL_SUPPLEMENT");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isRXO = availableData.StartsWith("RXO", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("RXO", options.Version) || isRXO) {
				return isRXO;
			}
			ORDER_DETAIL_SUPPLEMENT_RAS_O01 testORDER_DETAIL_SUPPLEMENT_RAS_O01 = new ORDER_DETAIL_SUPPLEMENT_RAS_O01();
			bool grpCCORDER_DETAIL_SUPPLEMENT_RAS_O01 = (testORDER_DETAIL_SUPPLEMENT_RAS_O01.CanConsume(availableData, options));
			if (IsRequired("ORDER_DETAIL_SUPPLEMENT", options.Version) || grpCCORDER_DETAIL_SUPPLEMENT_RAS_O01) {
				return grpCCORDER_DETAIL_SUPPLEMENT_RAS_O01;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "ORDER_DETAIL";
			}
        }

        static ORDER_DETAIL_RAS_O01() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(ORDER_DETAIL_RAS_O01));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (RXO != null) {
			string segmentValue = RXO.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (ORDER_DETAIL_SUPPLEMENT != null) {
			string segmentValue = ORDER_DETAIL_SUPPLEMENT.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

